﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using ABCTile.Models;

namespace ABCTile.DAL
{
    public class ABCTileInitializer : DropCreateDatabaseIfModelChanges<ABCDbContext>
    {
        protected override void Seed(ABCDbContext context)
        {
            var Roles = new List<Role>
            {
                new Role { RoleID= 1, RoleName="ProductManager"},
                new Role { RoleID= 2, RoleName="Architect"}
            };
            Roles.ForEach(r => context.Roles.Add(r));
            context.SaveChanges();

            var Users = new List<User>
            {
                new User{UserID = "student1", UserPW = "123456", UserFname = "Froilan", UserLname = "Mate", UserEmail = "student1@towson.edu", RoleID = 1},
                new User{UserID = "student2", UserPW = "123456", UserFname = "Mouhamadou ", UserLname = "Seye", UserEmail = "student1@towson.edu", RoleID = 1},
                new User{UserID = "student3", UserPW = "123456", UserFname = "Michael", UserLname = "Terry", UserEmail = "student1@towson.edu", RoleID = 2},
                new User{UserID = "student4", UserPW = "123456", UserFname = "Ivaylo", UserLname = "Todorchev", UserEmail = "student1@towson.edu", RoleID = 2},
                new User{UserID = "student5", UserPW = "123456", UserFname = "Anastasia", UserLname = "Reitz", UserEmail = "student1@towson.edu", RoleID = 1},
                new User{UserID = "student6", UserPW = "123456", UserFname = "David", UserLname = "Jeang", UserEmail = "student1@towson.edu", RoleID = 1},
                new User{UserID = "student7", UserPW = "123456", UserFname = "Casey", UserLname = "Rudd", UserEmail = "student1@towson.edu", RoleID = 2},
                new User{UserID = "student8", UserPW = "123456", UserFname = "Brittany", UserLname = "Weaver", UserEmail = "student1@towson.edu", RoleID = 2},
                new User{UserID = "student9", UserPW = "123456", UserFname = "Akeem", UserLname = "Egbebi", UserEmail = "student1@towson.edu", RoleID = 1},
                new User{UserID = "student10", UserPW = "123456", UserFname = "Cassandra", UserLname = "Akeley", UserEmail = "student1@towson.edu", RoleID = 1},
                new User{UserID = "student11", UserPW = "123456", UserFname = "Jamie", UserLname = "Xu", UserEmail = "student1@towson.edu", RoleID = 2},
                new User{UserID = "student12", UserPW = "123456", UserFname = "John", UserLname = "Schuler", UserEmail = "student1@towson.edu", RoleID = 2},
                new User{UserID = "student13", UserPW = "123456", UserFname = "Zouheir", UserLname = "Mdarhi-Alaoui", UserEmail = "student1@towson.edu", RoleID = 2}
            };

            Users.ForEach(u => context.Users.Add(u));
            context.SaveChanges();

            var Manufactures = new List<Manufacture>
            {
                new Manufacture{Name = "BestTile", City = "Towson", State = "MD", Street = "7800 YorkRd", Zip = "21204"},
                new Manufacture{Name = "WallTile", City = "Baltimroe", State = "MD", Street = "5533 LochRaven", Zip = "21206"},
                new Manufacture{Name = "ILoveTile", City = "Baltimore", State = "MD", Street = "1234 Belair", Zip = "21205"}
            };

            Manufactures.ForEach(m => context.Manufactures.Add(m));
            context.SaveChanges();

            var Colors = new List<Color>
            {
                new Color{ColorID = "#000000", ColorName = "Black"},
                new Color{ColorID = "#0000FF", ColorName = "Blue"},
                new Color{ColorID = "#A52A2A", ColorName = "Brown"},
                new Color{ColorID = "#D2691E", ColorName = "Chocolate"},
                new Color{ColorID = "#FFFFFF", ColorName = "White"},
                new Color{ColorID = "#FFFF00", ColorName = "Yellow"},
                new Color{ColorID = "#FF0000", ColorName = "Red"},
                new Color{ColorID = "#800080", ColorName = "Purple"},
            };

            Colors.ForEach(c => context.Colors.Add(c));
            context.SaveChanges();

            var Shapes = new List<Shape>
            {
                new Shape{ShapeName = "Rectangles"},
                new Shape{ShapeName = "Hexagons"},
                new Shape{ShapeName = "Triangles"}
            };

            Shapes.ForEach(s => context.Shapes.Add(s));
            context.SaveChanges();

            var Tiles = new List<Tile>
            {
                new Tile{Series = "TC01", Description = "Best Tile Ever!!!!", SizeX = 4, SizeY = 4, ManufactureID = 1, ColorID = "#000000",  ShapeID = 1 },
                new Tile{Series = "TC02", Description = "Good Tile", SizeX = 3, SizeY = 3, ManufactureID = 1, ColorID = "#0000FF",  ShapeID = 2 },
                new Tile{Series = "TC03", Description = "Worst Tile Ever!!!!", SizeX = 4, SizeY = 4, ManufactureID = 1, ColorID = "#A52A2A",  ShapeID = 3 },
                new Tile{Series = "TC04", Description = "My Tile!!!!", SizeX = 4, SizeY = 4, ManufactureID = 1, ColorID = "#D2691E",  ShapeID = 1 },
                new Tile{Series = "TC05", Description = "Best Tile Ever!!!!", SizeX = 4, SizeY = 4, ManufactureID = 1, ColorID = "#FFFFFF",  ShapeID = 3 },
                new Tile{Series = "AB01", Description = "Best Tile Ever!!!!", SizeX = 2, SizeY = 2, ManufactureID = 1, ColorID = "#FFFF00",  ShapeID = 1 },
                new Tile{Series = "AB02", Description = "Best Tile Ever!!!!", SizeX = 4, SizeY = 4, ManufactureID = 1, ColorID = "#FF0000",  ShapeID = 1 },
                new Tile{Series = "AB03", Description = "Best Tile Ever!!!!", SizeX = 4, SizeY = 4, ManufactureID = 1, ColorID = "#800080",  ShapeID = 1 },
                new Tile{Series = "AB04", Description = "Best Tile Ever!!!!", SizeX = 5, SizeY = 5, ManufactureID = 2, ColorID = "#000000",  ShapeID = 2 },
                new Tile{Series = "AB05", Description = "Best Tile Ever!!!!", SizeX = 5, SizeY = 5, ManufactureID = 2, ColorID = "#0000FF",  ShapeID = 1 },
                new Tile{Series = "GS01", Description = "Best Tile Ever!!!!", SizeX = 4, SizeY = 4, ManufactureID = 2, ColorID = "#000000",  ShapeID = 2 },
                new Tile{Series = "GS01", Description = "Best Tile Ever!!!!", SizeX = 4, SizeY = 3, ManufactureID = 2, ColorID = "#A52A2A",  ShapeID = 1 },
                new Tile{Series = "GS02", Description = "Best Tile Ever!!!!", SizeX = 3, SizeY = 4, ManufactureID = 2, ColorID = "#D2691E",  ShapeID = 1 },
                new Tile{Series = "GS03", Description = "Best Tile Ever!!!!", SizeX = 4, SizeY = 4, ManufactureID = 2, ColorID = "#000000",  ShapeID = 3 },
                new Tile{Series = "GS04", Description = "Best Tile Ever!!!!", SizeX = 2, SizeY = 1, ManufactureID = 3, ColorID = "#FFFFFF",  ShapeID = 1 },
                new Tile{Series = "GS05", Description = "Best Tile Ever!!!!", SizeX = 4, SizeY = 4, ManufactureID = 3, ColorID = "#000000",  ShapeID = 1 },
                new Tile{Series = "OT01", Description = "Best Tile Ever!!!!", SizeX = 1, SizeY = 1, ManufactureID = 3, ColorID = "#FFFF00",  ShapeID = 1 },
                new Tile{Series = "OT02", Description = "Best Tile Ever!!!!", SizeX = 4, SizeY = 4, ManufactureID = 3, ColorID = "#FFFF00",  ShapeID = 2 },
                new Tile{Series = "OT03", Description = "Best Tile Ever!!!!", SizeX = 3, SizeY = 3, ManufactureID = 3, ColorID = "#FFFF00",  ShapeID = 2 },
                new Tile{Series = "OT04", Description = "Best Tile Ever!!!!", SizeX = 4, SizeY = 4, ManufactureID = 3, ColorID = "#800080",  ShapeID = 1 },
                new Tile{Series = "OT05", Description = "Best Tile Ever!!!!", SizeX = 5, SizeY = 5, ManufactureID = 3, ColorID = "#800080",  ShapeID = 2 }
            };

            Tiles.ForEach(s => context.Tiles.Add(s));
            context.SaveChanges();


            var Statuses = new List<Status>
            {
                new Status {StatusName = "Initialized"},
                new Status {StatusName = "In Progress"},
                new Status {StatusName = "In Bidding"},
                new Status {StatusName = "Won"},
                new Status {StatusName = "Closed"},
            };

            Statuses.ForEach(s => context.Statuses.Add(s));
            context.SaveChanges();

            var Projects = new List<Project>
            {
                new Project{projectName = "ProjectA", streetAddress = "3457 Garden Street", city = "Baltimore", state = "Maryland", zip = 23456, bid_date = DateTime.Parse("2011-11-02"), building_type = "House", work_type ="Renovation" , architectureID = 3423, ownerID = 2123, bid_submit_type = "unknown", StatusID = 5 },
                new Project{projectName = "ProjectB", streetAddress = "1234 Garden Street", city = "Baltimore", state = "Maryland", zip = 23456, bid_date = DateTime.Parse("2011-11-12"), building_type = "House", work_type ="Renovation" , architectureID = 3423, ownerID = 2123, bid_submit_type = "unknown", StatusID = 4 },
                new Project{projectName = "ProjectC", streetAddress = "5678 Garden Street", city = "Baltimore", state = "Maryland", zip = 23456, bid_date = DateTime.Parse("2011-11-22"), building_type = "House", work_type ="Renovation" , architectureID = 3423, ownerID = 2123, bid_submit_type = "unknown", StatusID = 3 },
                new Project{projectName = "ProjectD", streetAddress = "5566 Garden Street", city = "Baltimore", state = "Maryland", zip = 23456, bid_date = DateTime.Parse("2012-01-02"), building_type = "House", work_type ="Renovation" , architectureID = 3423, ownerID = 2123, bid_submit_type = "unknown", StatusID = 2 },
                new Project{projectName = "ProjectE", streetAddress = "8800 Garden Street", city = "Baltimore", state = "Maryland", zip = 23456, bid_date = DateTime.Parse("2012-01-02"), building_type = "House", work_type ="Renovation" , architectureID = 3423, ownerID = 2123, bid_submit_type = "unknown", StatusID = 1 },
            };

            Projects.ForEach(p => context.Projects.Add(p));
            context.SaveChanges();

            var Companies = new List<Company>
            {
                new Company{Branch_Seq = "0", Contact_Role = "Vender", Contact_Person_ID = "alde2", Company_Name = "Acme Corp.", Office_Phone = "(555)555-5555",  Office_Fax = "(555)555-5556", Cell_Phone = "(555)555-6666", Company_url = "www.acme.com", Street_Address = "78 Waldorf Street", City = "Baltimore", State = "MD", Zip = "66778", Comments = "Working" },
                new Company{Branch_Seq = "1", Contact_Role = "Customer", Contact_Person_ID = "bbkk04", Company_Name = "Mason & Sons", Office_Phone = "(666)666-6666",  Office_Fax = "(666)666-6667", Cell_Phone = "(666)666-7777", Company_url = "www.cmasonandson.com", Street_Address = "6578 Darth Drive", City = "Chicago", State = "IL", Zip = "99875", Comments = "Busy" },
                new Company{Branch_Seq = "2", Contact_Role = "Owner", Contact_Person_ID = "ilme18", Company_Name = "Atlantic Industries", Office_Phone = "(888)888-8888",  Office_Fax = "(888)888-8889", Cell_Phone = "(888)888-9999", Company_url = "www.atlantic.com", Street_Address = "339 Wallaby Way", City = "New York", State = "NY", Zip = "89083", Comments = "Free" },
            };

            Companies.ForEach(s => context.Company.Add(s));
            context.SaveChanges();
        }

    }
}